package com.spic.business.registrationform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.business.registrationform.domain.ArchiveStaffPositionChange;
import com.spic.business.registrationform.service.IArchiveStaffPositionChangeService;

/**
 * 员工岗位变动情况Controller
 * 
 * @author spic
 * @date 2022-07-20
 */
@RestController
@RequestMapping("/change")
public class ArchiveStaffPositionChangeController extends BaseController
{
    @Autowired
    private IArchiveStaffPositionChangeService archiveStaffPositionChangeService;

    /**
     * 查询员工岗位变动情况列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ArchiveStaffPositionChange archiveStaffPositionChange)
    {
        startPage();
        List<ArchiveStaffPositionChange> list = archiveStaffPositionChangeService.selectArchiveStaffPositionChangeList(archiveStaffPositionChange);
        return getDataTable(list);
    }

    /**
     * 导出员工岗位变动情况列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveStaffPositionChange archiveStaffPositionChange) throws IOException {
        List<ArchiveStaffPositionChange> list = archiveStaffPositionChangeService.selectArchiveStaffPositionChangeList(archiveStaffPositionChange);
        ExcelUtil<ArchiveStaffPositionChange> util = new ExcelUtil<ArchiveStaffPositionChange>(ArchiveStaffPositionChange.class);
        util.exportExcel(response, list, "员工岗位变动情况数据");
    }

    /**
     * 获取员工岗位变动情况详细信息
     */
    @GetMapping(value = "/{changeId}")
    public AjaxResult getInfo(@PathVariable("changeId") Long changeId)
    {
        return AjaxResult.success(archiveStaffPositionChangeService.selectArchiveStaffPositionChangeByChangeId(changeId));
    }

    /**
     * 新增员工岗位变动情况
     */
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveStaffPositionChange archiveStaffPositionChange)
    {
        return toAjax(archiveStaffPositionChangeService.insertArchiveStaffPositionChange(archiveStaffPositionChange));
    }

    /**
     * 修改员工岗位变动情况
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveStaffPositionChange archiveStaffPositionChange)
    {
        return toAjax(archiveStaffPositionChangeService.updateArchiveStaffPositionChange(archiveStaffPositionChange));
    }

    /**
     * 删除员工岗位变动情况
     */
	@DeleteMapping("/{changeIds}")
    public AjaxResult remove(@PathVariable Long[] changeIds)
    {
        return toAjax(archiveStaffPositionChangeService.deleteArchiveStaffPositionChangeByChangeIds(changeIds));
    }
}
